package com.fsoft.manager.file.controller;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.fsoft.core.common.base.contorller.BaseController;
import com.fsoft.core.common.exceptions.RRException;
import com.fsoft.core.utils.DateTimeUtils;
import com.fsoft.core.utils.RetVo;
import com.fsoft.manager.file.entity.SmsBsFileVo;
import com.fsoft.manager.file.service.SmsBsFileService;

@Controller
@RequestMapping("/sms-file")
public class SmsBsFileController extends BaseController {
	@Autowired
	private SmsBsFileService service;

	@ResponseBody
	@RequestMapping(value = "/save", method = RequestMethod.PUT)
	public RetVo save(@RequestBody SmsBsFileVo fileVo) throws Exception {
		try {
			if (StringUtils.isBlank(fileVo.getBsId()))
				throw new RRException("bsId标识不允许为空");
			if (StringUtils.isBlank(fileVo.getFilePath()))
				throw new Exception("文件路径filePath标识不允许为空");
			fileVo.setModifyTime(DateTimeUtils.getNowTime());
			fileVo.setModifyUserId(getUserId());
			service.save(fileVo);
			return RetVo.ok();
		} catch (Exception e) {
			return RetVo.error(e.getMessage());
		}
	}

}
